<template>
	<div class="">
		<div id="carttp">
			<header class="top_bar">
				<a onclick="window.history.go(-1)" class="icon_back"></a>
				<h3 class="cartname">评价商品</h3>
				<a href="javascript:void(0)" class="icon_menu"></a>
			</header>
		</div>
		<main class="cart_box background_fff">
			<div class="border_bot_999">
				<div class="height80 padding_lf10_rg10 padding_top10_bot10">
					<div class="fl rate_product_img_wrap">
						<img :src="root + ProductsList.ImgPath" />
					</div>
					<div class="fl margin_left20">
						<p style="line-height: 30px;">商品评分</p>
						<yd-cell-item>
							<yd-rate slot="left" v-model="ProductsList.ReviewMark" size="22px" padding="10px"></yd-rate>
						</yd-cell-item>
					</div>
				</div>
				<div class="background_f0">
					<textarea v-model="ProductsList.ReviewContent" class="background_f0 pad10 width100 border_bot_999" placeholder="请填写您的评价(500字以内)" style="height: 100px;"></textarea>
				</div>
				<div class="text_align_rg padding_lf10_rg10 padding_top10_bot10 ">
					<input @click="SubmitComment(ProductsList)" type="button" value="提交评价" class="submit_comment_btn"/>
				</div>
			</div>
		</main>
	</div>
</template>
<script>
	import { Toast } from 'mint-ui';
	export default {
		created() {
			let _this = this
			console.log('_this.$route.query.item', _this.$route.query.item)
			_this.OrderId = _this.$route.query.OrderId
			_this.ProductsList = _this.$route.query.item
			_this.$set(_this.ProductsList, 'ReviewMark', 5)
			_this.$set(_this.ProductsList, 'ReviewContent', '')
		},
		data() {
			return {
				root: this.root,
				OrderId: 0,
				ProductsList: {},
			}
		},
		mounted() {
			let _this = this;
		},
		methods: {
			SubmitComment(it) {
				let _this = this
				_this.$http.post('/client/Comments', {
					OrderId: _this.OrderId,
					ProductId: it.ProductId,
					SkuId:it.SkuId,
					ReviewContent:it.ReviewContent,
					ReviewMark:it.ReviewMark,
					
				}, localStorage.Authorization, res => {
					console.log('提交评价res', res)
					if(res.code === 200) {
						Toast(res.data)
						setTimeout(function(){
							_this.$router.go(-1)
						}, 1000)
					}else {
						Toast(res.error)
					}
				})
			}
		},
		watch: {

		}
	}
</script>
<style scoped="scoped">
	.height80 {
		height: 80px;
	}
	
	.rate_product_img_wrap {}
	
	.rate_product_img_wrap img {
		width: 60px;
		height: 60px;
	}
	.margin_left20{
		margin-left: 20px;
	}
	.pad10{
		padding: 10px;
	}
	.submit_comment_btn{
		border: 1px solid red;
		border-radius: 5px;
		padding: 4px 10px;
	}
</style>